package activiti
/**
 * 流程解决方案
 */
class ActSolution {
    String name //名称
    String bm//别名  用于权限名
    String status='新建' // 状态
    String typeCode// 分类 编号
    String typeName// 分类 名称
    String ctraterRealName //创建人 名称
    String ctraterUserName // 创建人 username
    Date dateCreated//创建时间
    Date lastUpdated//最后更新的时间
    String description  // 描述
    ActModel actModel// 流程定义
    Date fbsj//发布时间
    Integer fromId// 复制时的来源id
    Boolean syApp;// 是否开启app 编辑发起的 功能
    static  hasMany = [mx:ActSolutionMx]
    static constraints = {
        description nullable: true,maxSize: 4000
        ctraterRealName nullable: true
        ctraterUserName nullable: true
        actModel nullable: true
        bm nullable: true
        status nullable: true
        typeCode nullable: true
        typeName nullable: true
        fbsj nullable: true
        fromId nullable: true
        syApp nullable: true
    }

    transient utilsService
    def buildDomain() {
        def b = [:] + this.properties
        def param = [allowformat: true, allowprecision: false]
        b = utilsService.truncProp(this, b, param) { amap ->
            amap << ['id': this.id]
            amap << ['controlerName': this.actModel?.openJs?.controlerName]
            amap << ['ywdescription': this.actModel?.openJs?.description]
            if(syApp) amap<<["syAppName":"是"]
            else  amap<<["syAppName":"否"]
        }
         b
    }

    def buildDomainList(list) {
        def rds = []
        list.each {
            def b = [:] + it.properties
            def param = [allowformat: true, allowprecision: false]
            b = utilsService.truncProp(it, b, param) { amap ->
                amap << ['id': it.id]
                amap << ['controlerName': it.actModel?.openJs?.controlerName]
                amap << ['ywdescription': it.actModel?.openJs?.description]
                if(it.syApp) amap<<["syAppName":"是"]
                else  amap<<["syAppName":"否"]
            }
            rds << b
        }
        return rds
    }
    static ActSolution  sxSolution(Map map){
        def result
        if (map.modelId){
            result=ActSolution.findByActModelAndStatus(ActModel.get(map.modelId),"已发布")
        }
        result
    }
}
